﻿@using DNA.OpenAPI.Rss;
@model IEnumerable<RssItem>
@{
    Ajax.Dna().Accordion()
           .Options(opts =>
           {
               opts.Icons = new AccordionOptions.HeaderIconsStyle()
               {
                   HeaderCssClass = "d-accordion-icon",
                   HeaderSelectedIconCssClass = "d-accordion-icon-select"
               };
               opts.AutoHeight = false;
               opts.Navigation = true;
           })
           .Name("Accordion_" + Guid.NewGuid().ToString().Substring(0, 5))
           .Sections(sections =>
           {
               foreach (var ri in Model)
               {
                   var _textLen = (int)ViewData["TextLen"];
                   var _postTitle = ri.Title;
                   var _showAuthor = (bool)ViewData["ShowAuthor"];
                   var _showDate = (bool)ViewData["ShowDate"];
                   var rssItem = ri;
                   _postTitle = Html.Cut(_postTitle, _textLen);
                   sections.Add(_postTitle).Template(@<text>
    <table style="width: 100%;">
        @if (_showAuthor || _showDate)
        {
            <tr>
                <td colspan="2">
                    <ul class="d-horizontal-list">
                        @if ((bool)ViewData["ShowAuthor"] && !string.IsNullOrEmpty(rssItem.Author))
                        {  
                            <li style="color: #cccccc; font-style: italic">@Html.Global("RES_POSTBY") @rssItem.Author
                            </li>
                        }
                        @if ((bool)ViewData["ShowDate"] && (!string.IsNullOrEmpty(rssItem.PubDate)))
                        { 
                            <li style="color: #cccccc; font-style: italic">
                                @rssItem.PubDate
                            </li>
                        }
                        @if ((rssItem.Categories != null) && (rssItem.Categories.Count > 0))
                        {
                            foreach (var cat in rssItem.Categories)
                            {
                            <li>@cat.Text</li>
                            }
                        }
                    </ul>
                </td>
            </tr>
        }
        <tr>
            <td style="vertical-align: top;">
                @if (rssItem.Enclosure != null)
                {
                    if (!string.IsNullOrEmpty(rssItem.Enclosure.ContentType) &&
                        rssItem.Enclosure.ContentType.StartsWith("image", StringComparison.OrdinalIgnoreCase) &&
                        !string.IsNullOrEmpty(rssItem.Enclosure.Url))
                    {
                        <div class="d-avatar">
                    <img src="@rssItem.Enclosure.Url" alt="@rssItem.Enclosure.Url" />
                    </div>
                    }
                }
            </td>
            <td style="vertical-align: top;">
                <p class="d-post-summary" title="@rssItem.Description" style="margin:0px;">
                    @Html.Cut(TextEngine.Text(rssItem.Description), 255)
                </p>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: right;">
                <a href="@rssItem.Link" class="d-link" rel="nofollow" target="_blank" >@Html.Global("RES_MORE")</a>
            </td>
        </tr>
    </table>
    </text>);
               }
           }).Render();
}
@Html.StartupScripts()
